package com.dcd.service.impl;

import com.dcd.mapper.Follow_userMapper;
import com.dcd.pojo.Follow_user;
import com.dcd.service.Follow_userService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
public class Follow_userServiceImpl implements Follow_userService {

    @Autowired(required = false)
    private Follow_userMapper fm;

    /**
     * 查询所有关注的用户(根据登录用户id查询)
     * @param follow_user_id 登录用户id
     * @return
     */
    @Override
    public List<Follow_user> selectFollowUser(int follow_user_id) {
        return fm.selectFollowUser(follow_user_id);
    }

    /**
     * 关注用户（添加）
     * @param follow_user 关注用户表对象
     * @return
     */
    @Override
    public boolean addFollowUser(Follow_user follow_user) {
        return fm.addFollowUser(follow_user)==1;
    }

    /**
     * 根据登入id查询用户详情
     * @param user_id 用户登入id
     * @return
     */
    @Override
    public Follow_user selectById(int user_id) {
        return fm.selectById(user_id);
    }

    /**
     * 根据被关注id查询粉丝数
     * @param cover_id 被关注id
     * @return
     */
    @Override
    public Follow_user selectByCoverId(int cover_id) {
        return fm.selectByCoverId(cover_id);
    }

    /**
     * 取消关注(删除)
     * @param follow_user 关注用户的对象
     * @return
     */
    @Override
    public boolean deleteFollowUser(Follow_user follow_user) {
        return fm.deleteFollowUser(follow_user)>0;
    }

    /**
     * 查询用户是否关注指定用户
     * @param follow_user
     * @return
     */
    @Override
    public boolean select_user_follow_user(Follow_user follow_user) {
        return fm.select_user_follow_user(follow_user)==1;
    }
}
